package com.ibm.ops.domain.report;

import com.ibm.ops.OpstoolConstant;
import com.ibm.ops.domain.OpsLogMetaDataType;
import com.ibm.ops.domain.metadata.OpsAuditLogHubReportMetaData;
import com.ibm.ops.domain.metadata.OpsAuditLogReportMetaData;


public final class OpsAuditLogHubReport extends OpsAuditLogReport{

	@Override
	protected OpsAuditLogReportMetaData constructOpsAuditLogReportMetaData(String metaData) {
		OpsAuditLogHubReportMetaData hubMetaData = new OpsAuditLogHubReportMetaData();
		hubMetaData.setType(OpsLogMetaDataType.HUB);
		hubMetaData.setMaster_no(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_MASTER_NO_START_IX, OpstoolConstant.HUB_REPORT_MASTER_NO_START_IX + OpstoolConstant.HUB_REPORT_MASTER_NO_LENGTH));
		hubMetaData.setStatus(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_STATUS_START_IX, OpstoolConstant.HUB_REPORT_STATUS_START_IX + OpstoolConstant.HUB_REPORT_STATUS_LENGTH));
		hubMetaData.setSender(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_SENDER_START_IX, OpstoolConstant.HUB_REPORT_SENDER_START_IX + OpstoolConstant.HUB_REPORT_SENDER_LENGTH));
		hubMetaData.setRecipient(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_RECIPIENT_START_IX, OpstoolConstant.HUB_REPORT_RECIPIENT_START_IX + OpstoolConstant.HUB_REPORT_RECIPIENT_LENGTH));
		hubMetaData.setTrans_type(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_TRANS_TYPE_START_IX, OpstoolConstant.HUB_REPORT_TRANS_TYPE_START_IX + OpstoolConstant.HUB_REPORT_TRANS_TYPE_LENGTH));
		hubMetaData.setEnvelopeid(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_ENVELOPEID_START_IX, OpstoolConstant.HUB_REPORT_ENVELOPEID_START_IX + OpstoolConstant.HUB_REPORT_ENVELOPEID_LENGTH));
		hubMetaData.setLogtime_in(this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_LOGTIME_IN_START_IX, OpstoolConstant.HUB_REPORT_LOGTIME_IN_START_IX + OpstoolConstant.HUB_REPORT_LOGTIME_IN_LENGTH));
		this.currentMetaData = hubMetaData;
		return hubMetaData;
	}

	@Override
	protected OpsAuditLogReportMetaDataKey retrieveOpsAuditLogReportMetaDataKey(String metaData) {
		String key = null;
		if(this.currentMetaData != null){
			if(this.currentMetaData instanceof OpsAuditLogHubReportMetaData){
				OpsAuditLogHubReportMetaData obj = ((OpsAuditLogHubReportMetaData) this.currentMetaData);
				key = obj.getSender() + obj.getRecipient() + obj.getTrans_type();
			}
			
		}else{
			key = this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_SENDER_START_IX, OpstoolConstant.HUB_REPORT_SENDER_START_IX + OpstoolConstant.HUB_REPORT_SENDER_LENGTH)
					+ this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_RECIPIENT_START_IX, OpstoolConstant.HUB_REPORT_RECIPIENT_START_IX + OpstoolConstant.HUB_REPORT_RECIPIENT_LENGTH)
					+ this.retrieveData(metaData, OpstoolConstant.HUB_REPORT_TRANS_TYPE_START_IX, OpstoolConstant.HUB_REPORT_TRANS_TYPE_START_IX + OpstoolConstant.HUB_REPORT_TRANS_TYPE_LENGTH);
		}
		return new OpsAuditLogReportMetaDataKey(key);
	}
}
